<xsl:stylesheet version="1.0"
	xmlns:date="http://exslt.org/dates-and-times"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ebe="http://cks/ebemethods"
	xmlns:ms="urn:schemas-microsoft-com:xslt"
  xmlns:dt="urn:schemas-microsoft-com:datatypes"
  exclude-result-prefixes="date ebe">

  <xsl:output omit-xml-declaration="yes" />

  <xsl:param name="IsBlogOwner" />
  <xsl:param name="RelativeUrl" />
  <xsl:param name="Language" />
  <xsl:param name="ShortDatePattern" />
  <xsl:param name="ShortTimePattern" />

  <xsl:template match="/">
    <div class="blogCommentContainer">
      <h3>
        <xsl:value-of select="ebe:res('LinkBack')" />
      </h3>
      <xsl:apply-templates select="rows/row"/>
    </div>
  </xsl:template>

  <xsl:template match="row">

    <div class="commentContainer">
      <xsl:variable name="publishedDate" select="date:parseDate(Created, 'yyyy-MM-dd HH:mm:ss')"/>
      <xsl:choose>
        <xsl:when test="LinkbackType = 'Pingback'">

          <span class="commentDate">
            <xsl:value-of select="ebe:res('PingbackFrom')" /> &#160;
            <a href="{substring-before(LinkingPost,',')}">
              <xsl:value-of select="BlogName"/>
            </a>&#160;
            <xsl:value-of select="ebe:res('PingbackOn')" />
            &#160;<xsl:value-of select="ms:format-date($publishedDate, $ShortDatePattern, $Language)"/>
          </span>

          <xsl:if test="LinkingPostExcerpt != ''">
            <blockquote class="commentText">
              [...] <xsl:call-template name="PreserveLineBreaks">
                <xsl:with-param name="text" select="LinkingPostExcerpt" />
              </xsl:call-template> [...]
            </blockquote>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>

          <span class="commentDate">
            <xsl:value-of select="ebe:res('TrackbackFrom')" />&#160;
            <a href="{substring-before(LinkingPost,',')}">
              <xsl:value-of select="BlogName"/>
            </a>&#160;
            <xsl:value-of select="ebe:res('TrackbackOn')" />&#160;
            &#160;<xsl:value-of select="ms:format-date($publishedDate, $ShortDatePattern, $Language)"/>
          </span>

          <blockquote>
            <xsl:value-of select="substring-after(LinkingPost,', ')"/>
          </blockquote>

          <xsl:if test="LinkingPostExcerpt != ''">
            <blockquote class="commentText">
              [...] <xsl:call-template name="PreserveLineBreaks">
                <xsl:with-param name="text" select="LinkingPostExcerpt" />
              </xsl:call-template> [...]
            </blockquote>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
      <hr class="commentSep"/>
    </div>
  </xsl:template>

  <xsl:template name="PreserveLineBreaks">
    <xsl:param name="text"/>
    <xsl:choose>
      <xsl:when test="contains($text,'&#xA;')">
        <xsl:value-of select="substring-before($text,'&#xA;')"/>
        <br/>
        <xsl:call-template name="PreserveLineBreaks">
          <xsl:with-param name="text">
            <xsl:value-of select="substring-after($text,'&#xA;')"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
